
cd "~/dropbox/immigration conjoint/Replication Files/Data"
use "ipsos_rep", clear

cd "~/dropbox/immigration conjoint/Replication Files/Output"
set scheme plotplain

// Table C1: Balance table

reg female2 i1.exp8_country i.exp8_skill i.exp8_age i.exp8_gender i.exp8_number ///
i.exp8_ideology i1.exp8_relatives i1.exp8_reasons

outreg2 using balance,  tex   label ctitle("Female") dec(3) ///
keep( 1.exp8_country 2.exp8_skill 2.exp8_age 2.exp8_gender 2.exp8_number 2.exp8_ideology 1.exp8_relatives 1.exp8_reasons ) ///
nonotes addnote("Standard error clustered at the individual level", "Omitted categories: Peru, Unqualified, Less than 40, Man, Alone, Right", "No Colombian relatives, New opportunities" , *p<.1; **p<.05; ***p<.01) ///
nocons nor2 noobs  addstat(R^2, e(r2), Obs., e(N)) addtext(Adjusted, No)  replace 

reg age_continuous i1.exp8_country i.exp8_skill i.exp8_age i.exp8_gender i.exp8_number ///
i.exp8_ideology i1.exp8_relatives i1.exp8_reasons

outreg2 using balance,  tex label  ctitle("Age")  ///
keep(1.exp8_country 2.exp8_skill 2.exp8_age 2.exp8_gender 2.exp8_number 2.exp8_ideology 1.exp8_relatives 1.exp8_reasons ) ///
addtext(Adjusted, Yes) dec(3) nocons addstat(R^2, e(r2), Obs., e(N))   nor2 noobs   append 

reg urban1 i1.exp8_country i.exp8_skill i.exp8_age i.exp8_gender i.exp8_number ///
i.exp8_ideology i1.exp8_relatives i1.exp8_reasons

outreg2 using balance,  tex label  ctitle("Urban")  ///
keep(1.exp8_country 2.exp8_skill 2.exp8_age 2.exp8_gender 2.exp8_number 2.exp8_ideology 1.exp8_relatives 1.exp8_reasons ) ///
addtext(Adjusted, Yes) dec(3) nocons addstat(R^2, e(r2), Obs., e(N))   nor2 noobs   append 

reg education i1.exp8_country i.exp8_skill i.exp8_age i.exp8_gender i.exp8_number ///
i.exp8_ideology i1.exp8_relatives i1.exp8_reasons

outreg2 using balance,  tex label  ctitle("Education")  ///
keep(1.exp8_country 2.exp8_skill 2.exp8_age 2.exp8_gender 2.exp8_number 2.exp8_ideology 1.exp8_relatives 1.exp8_reasons ) ///
addtext(Adjusted, Yes) dec(3) nocons addstat(R^2, e(r2), Obs., e(N))   nor2 noobs   append 

reg nse i1.exp8_country i.exp8_skill i.exp8_age i.exp8_gender i.exp8_number ///
i.exp8_ideology##i.left i1.exp8_relatives i1.exp8_reasons

outreg2 using balance,  tex label  ctitle("N")  ///
keep(1.exp8_country 2.exp8_skill 2.exp8_age 2.exp8_gender 2.exp8_number 2.exp8_ideology 1.exp8_relatives 1.exp8_reasons ) ///
addtext(Adjusted, Yes) dec(3) nocons addstat(R^2, e(r2), Obs., e(N))   nor2 noobs   append 

// Table C2: Non-response table

balancetable non_response age_continuous female2 education nse urban1 using "non_response.tex", replace

// Table C3: Matching results

reg choice_exp8 exp8_country_1 i0.exp8_country_2 exp8_skill_1 exp8_skill_2 ///
exp8_age_1 exp8_age_2 exp8_gender_1 exp8_gender_2 exp8_number_1 exp8_number_2 ///
exp8_ideology_2 exp8_ideology_1 exp8_relatives_2 exp8_relatives_1 ///
exp8_reasons_1 exp8_reasons_2 [aw=ipw], vce(cluster respondent_serial) 

outreg2 using matching,  tex   label ctitle("Choice") dec(3) ///
keep(exp8_country_1 exp8_skill_1 exp8_age_1 exp8_gender_1 exp8_number_1 exp8_ideology_2 exp8_relatives_2 exp8_reasons_1) ///
nonotes addnote("Standard error clustered at the individual level", "Omitted categories: Peru, Low-skilled, Less than 40, Man, Alone, Right", "No Colombian relatives, New opportunities" , *p<.1; **p<.05; ***p<.01) ///
nocons nor2 noobs  addstat(R^2, e(r2), Obs., e(N)) addtext(Adjusted, No)  replace 

reg support_exp8 exp8_country_1 i0.exp8_country_2 exp8_skill_1 exp8_skill_2 ///
exp8_age_1 exp8_age_2 exp8_gender_1 exp8_gender_2 exp8_number_1 exp8_number_2 ///
exp8_ideology_2 exp8_ideology_1 exp8_relatives_2 exp8_relatives_1 ///
exp8_reasons_1 exp8_reasons_2 [aw=ipw], vce(cluster respondent_serial)

outreg2 using matching,  tex   label ctitle("Support") dec(3) ///
keep(exp8_country_1 exp8_skill_1 exp8_age_1 exp8_gender_1 exp8_number_1 exp8_ideology_2 exp8_relatives_2 exp8_reasons_1) ///
nonotes addnote("Standard error clustered at the individual level", "Omitted categories: Peru, Low-skilled, Less than 40, Man, Alone, Right", "No Colombian relatives, New opportunities" , *p<.1; **p<.05; ***p<.01) ///
nocons nor2 noobs  addstat(R^2, e(r2), Obs., e(N)) addtext(Adjusted, No)  append 

// Figure C1: No missing results

reg choice_no_missing exp8_country_1 i0.exp8_country_2 exp8_skill_1 exp8_skill_2 ///
exp8_age_1 exp8_age_2 exp8_gender_1 exp8_gender_2 exp8_number_1 exp8_number_2 ///
exp8_ideology_2 exp8_ideology_1 exp8_relatives_2 exp8_relatives_1 ///
exp8_reasons_1 exp8_reasons_2, vce(cluster respondent_serial) 

coefplot, drop(_cons) xline(0) omitted baselevels graphregion(color(white)) ///
 xtitle ("") headings(exp8_country_1="{bf:Country}" ///
 exp8_skill_1="{bf:Skills}" exp8_age_1="{bf:Age}" exp8_gender_1="{bf:Gender}" ///
 exp8_number_1="{bf:Number}" exp8_ideology_2="{bf:Ideology}" ///
 exp8_relatives_2="{bf:Relatives}" exp8_reasons_1="{bf:Reason}") ///
 coeflabels (exp1_army_enc_1="Venezuela" exp8_pro_2="High-skilled" exp8_age_2="More than 40" exp8_gender_2="Woman" ///
 exp8_number_2="With family" exp8_ideology_1="Right" exp8_relatives_1="Yes" ///
 exp8_reason_2="Economic opportunities", labsize(vsmall))
 graph export "plot_conjoint_nommiss.png", replace 
